Pipe output from '/sbin/sysctl -n' through sed to remove spaces/tabs#76
Open
PaulGale wants to merge 2 commits intothias:masterfrom
Open
Pipe output from '/sbin/sysctl -n' through sed to remove spaces/tabs#76PaulGale wants to merge 2 commits intothias:masterfrom
PaulGale wants to merge 2 commits intothias:masterfrom
Conversation
|
@thias Any chance of getting this merged and released, if you're still looking? |
|
In the absence of action here, I have taken the liberty of forking and merging this PR as well as those of Phil-Friderici and spindyckx. It has been published as purplejac/sysctl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The exec resource
"enforce-sysctl-value-${qtitle}"for enforcing sysctl values fails for kernel parameters whose values are returned as a white space separated tuple.Example:
% /sbin/sysctl -n net.ipv4.tcp_wmem4096 229376 4194304Each value in the results is separated by a horizontal tab which, if not removed, causes the call to
/usr/bin/testto always fail and Puppet to report that a change has been applied when none should have.One can verify the presence of tabs in the output by piping it through
/usr/bin/xxd.% /sbin/sysctl -n net.ipv4.tcp_wmem | xxd00000000: 3430 3936 0932 3239 3337 3609 3431 3934 4096.229376.419400000010: 3330 340a 304.Tabs are the bytes with the value
09.By piping the output through sed tabs are converted to a single white space making comparison possible:
% /sbin/sysctl -n net.ipv4.tcp_wmem | sed -r -e 's/[ \t]+/ /g' | xxd00000000: 3430 3936 2032 3239 3337 3620 3431 3934 4096 229376 419400000010: 3330 340a 304.Space characters are the bytes with the value
20.I would have included an automated unit test to verify this but I am unfamiliar with how write tests for Puppet modules. However, I did test it manually and it works on RHEL 8.
Kernel parameters that don't contain tabs are unaffected and are enforced as normal.